#include "Reactor.hpp"
#include "listener.hpp"
int main(int argc,char* argv[])
{
    if (argc != 2)
    {
        std::cout << "Use selectserver + port!" << std::endl;
        return 1;
    }
    uint16_t port = std::stoi(argv[1]);
    listner _listner(port);
    _listner.Init();
    Reactor reactor;
    connection_t con = std::make_shared<Connection>(_listner.Fd());
    
    con->InitCB(
        [&](Reactor*owner) {  _listner.Acceptor(&reactor);},
        nullptr,
        nullptr
    );
    
    con->Setevents(EPOLLIN | EPOLLET);

    reactor.Init(); //先创建epoll模型再插入到内核当中
    reactor.InsertConnection(con);
    reactor.Loop();
    return 0;
}